package com.mission.schedule.CommonDialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.StyleRes;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
import android.widget.Toast;

import com.google.gson.Gson;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.RequestParams;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest.HttpMethod;
import com.mission.schedule.R;
import com.mission.schedule.applcation.App;
import com.mission.schedule.bean.NoteTypeBean;
import com.mission.schedule.bean.qd606.NoteTitleDetailBean;
import com.mission.schedule.constants.ShareFile;
import com.mission.schedule.constants.URLConstants;
import com.mission.schedule.service.NoteService;
import com.mission.schedule.utils.NetUtil;
import com.mission.schedule.utils.ProgressUtil;
import com.mission.schedule.utils.SharedPrefUtil;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * 清单子项对话框
 * Created by liwei on 2017/4/18.
 */

public class NewSixTaskDetailDialog extends Dialog {


    CallBack callBack;

    SharedPrefUtil sharedPrefUtil = null;
    Context context;
    WindowManager windowManager;

    String UserId = "";
    ProgressUtil progressUtil;

    public NewSixTaskDetailDialog(@NonNull final Context context, @StyleRes final int themeResId,
                                  final WindowManager windowManager) {
        super(context, themeResId);
        this.context = context;
        this.windowManager = windowManager;

        setCanceledOnTouchOutside(true);
        sharedPrefUtil = new SharedPrefUtil(context,
                ShareFile.USERFILE);
        UserId = sharedPrefUtil.getString(context,
                ShareFile.USERFILE, ShareFile.USERID, "");
        progressUtil = new ProgressUtil();
        View view = LayoutInflater.from(context).inflate(R.layout.dialog_six_task_right_menu, null);
        setContentView(view);

        view.findViewById(R.id.copy_all).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                callBack.copyall();
                dismiss();
            }
        });
        view.findViewById(R.id.copy_calender).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                callBack.weixin();
                dismiss();
            }
        });
        view.findViewById(R.id.save_note).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                callBack.savenote();
                dismiss();
            }
        });
        view.findViewById(R.id.share).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                callBack.share();
                dismiss();
            }
        });
        view.findViewById(R.id.share_weixin).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                callBack.weixin();
                dismiss();
            }
        });
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Window window = getWindow();
        WindowManager.LayoutParams params = window.getAttributes();
        window.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);
        params.width = windowManager.getDefaultDisplay().getWidth() - 30;
        params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        window.setAttributes(params);
    }


    public interface CallBack {

        void savenote();

        void weixin();

        void copyall();

        void copy();

        void share();

    }

    public CallBack getCallBack() {
        return callBack;
    }

    public void setCallBack(CallBack callBack) {
        this.callBack = callBack;
    }
}
